<%@ page contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<!DOCTYPE HTML>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<title>搜索--${searchResult.search}</title>
	<link rel="stylesheet" href="../css/commodity.css">
	<link href="../css/main.css" type="text/css" rel="stylesheet">
	<link rel="stylesheet" href="../css/commodity.css">
	<link rel="stylesheet" href="../css/demo.css">
	<link rel="stylesheet"  href="../css/component.css">
	<link rel="stylesheet" href="../css/content.css">
	<link rel="stylesheet" href="../css/cart.css">
	<link rel="stylesheet" href="../css/search.css">
	
	<style type="text/css">
	#more{
		border:1px solid gray;
		width: 100%; background-color: #34393f;text-align: center;color: white;
	}
	#more:HOVER {
			background-color: #34394a;
			cursor:pointer;
	}
	</style>
</head>
<body>
	<div class="wrap">
		<div class="logo">
		<!--头部-->
			<a href=""><img src="../images/dota2_logn.png" alt="恋尚优饰品交易中心"></a>
			<div class="login">
				<c:if test="${not empty userInfo }">
						<div class="user">
							<div class="user_img">
								<img src="../images/user.png" alt="" />
							</div>
							<div class="user_name" onmouseover="$('#user_name_none').css('display', 'block');"
								onmouseout="$('#user_name_none').css('display', 'none');">
								<a href="" id="user_name_a">
									<span>${userInfo. uName}</span> <b class="caret"></b>
								</a>
								<ul id="user_name_none">
									<li class="user_home"><a
										href="/index.php/home/User/my.html">个人主页</a></li>
									<li class="out_login"><a href="javascript:void(0)"
										id="quit" onclick="loginOut()">退出登录</a></li>
								</ul>
							</div>
						</div>
					</c:if>
					<c:if test="${ empty userInfo }">
					<!-- start -->
					<div class="morph-button morph-button-modal morph-button-modal-2 morph-button-fixed">
						<button type="button" id="login_b" class="login_box">登录</button>
						<div class="morph-content">
							<div>
								<div class="content-style-form content-style-form-1">
									<span class="icon icon-close">×</span>
									<h2>会员登录</h2>
									<form action="" method="post" id="denglu">
										<p>
											<label>用户名：</label><input placeholder="请输入用户名" name="uName"
												id="login_name" type="text"><span></span>
										</p>
										<p>
											<label>密码：</label><input placeholder="请输入登录密码" name="uPwd"
												id="login_pass" value="" type="password"><span></span>
										</p>
										<p>
											<label>验证码：</label><input id="code" placeholder="请输入验证码"
												type="text"> <img src="../front/valiCodeImg/login"
												alt="验证码" id="code_img"
												onclick="this.src='../front/valiCodeImg/login?'+Math.random()"
												style="margin-left: 40px; width: 150px; height: 45px; cursor: pointer;"><span
												id="code_info"
												style="font-size: 15px; margin-left: 20px; color: red"></span>
										</p>
										<p>
											<input value="登录" id="login_t" class="login_btn"
												type="button">
										</p>
										<div>
											<a href="">忘记密码?</a>
										</div>
									</form>
								</div>
							</div>
						</div>
					</div>
					<div
						class="morph-button morph-button-modal morph-button-modal-3 morph-button-fixed">
						<button type="button" id="login_b" class="register">注册</button>
						<div class="morph-content">
							<div>
								<div class="content-style-form content-style-form-2">
									<span class="icon icon-close">×</span>
									<h2>会员注册</h2>
									<form id="zuce">
										<p>
											<label class="p1">用户名：</label> <input placeholder="请输入用户名"
												class="reg reg_name" name="uName" type="text"> <span>*请输入5到20位字符的账户</span>
										</p>

										<p>
											<label class="p1">密码：</label> <input placeholder="请输入密码"
												class="reg reg_pwd" name="uPwd" type="password"> <span>*请输入7到20位字符的密码，必须包含数字、字母</span>
										</p>
										<p>
											<label class="p1">确认密码：</label> <input placeholder="确认密码"
												class="reg reg_reUpwd" name="reuPwd" type="password">
											<span>*请输入7到20位字符的密码，必须包含数字、字母</span>
										</p>
										<p>
											<label class="p1">邮箱：</label> <input placeholder="请输入邮箱"
												class="reg reg_email" name="uEmail" type="text"> <span>*请输入正确的邮箱</span>
										</p>

										<p>
											<label class="p1">手机号码：</label> <input placeholder="请输入手机号码"
												class="reg reg_phone" name="uPhone" type="text"> <span>*请输入正确的手机号码以保证找回密码</span>
										</p>

										<!-- <p>
												<label class="p1">密钥：</label>
												<input placeholder="请输入密钥" class="reg" name="密钥" type="text">
												<span>*请输入5到20位字符密钥可以是数字、字母、一段话（用于密码找回，请牢记）</span>
											</p> -->

										<p>
											<label class="p1">验证码：</label> <input id="code"
												placeholder="请输入验证码" style="width: 180px" class="reg"
												name="code" type="text"> <img
												src="../front/valiCodeImg/register" alt="验证码"
												style="margin-left: 25px; cursor: pointer;"
												onclick="this.src='../front/valiCodeImg/register?'+Math.random()"
												id="reg_img"> <span class="reg_code"
												style="line-height: 45px"></span>
										</p>
										<p>
											<input value="提交注册" id="login_t" class="zuce_btn"
												type="button">
										</p>
									</form>
								</div>
							</div>
						</div>
					</div>
					</c:if>
				</div>
		</div>
		<!--头部end-->
		<div class="bodyer">
			<div class="container">
			<!--主体内容-->
			<div class="site">
			<!-- 位置 -->
				<div class="home_icon">
						<a href=""><img src="../images/home_icon.png" alt=""></a>
					</div>
					<div class="triangle"></div>
					<div class="site_sp">
						<a href="">饰品市场</a>
					</div>
					<div class="triangle1"></div>
					<div class="site_ss">
						搜索
					</div>

			<!-- 位置end -->
			</div>
			<div class="ndb">
				<!-- 导航栏 -->
					<div class="ndb_img">
						<img src="../images/Dota-2.png" width="18" height="18" alt="" /><span>恋尚优</span>
					</div>
					<div class="search">
					<!--商品搜索-->
						<div class="mall-top-title">
							<div class="search_input">
								<form >
									<input type="text" value="${searchResult.search}" id="search_input" placeholder="点击搜索 这里有你想要的" name="search"/>
									<a href="javascript:void(0);" onclick="submitSearchForm();"><img src="../images/search.png" alt="" /></a>
								</form>
							</div>
						</div>
						<div class="slider">
							<div class="slider_1"></div>
						</div>
					<!-- 商品搜索end -->
					</div>
				<!-- 导航栏end -->
				</div>
				<c:if test="${searchResult.status==200 and fn:length(searchResult.data) >0}">
				<div class="new_commodity">
						<div class="new_commodity_bg">
							<c:forEach items="${searchResult.data}" var="info">
								<div class="new_commodity_info">
									<div class="new_commodity_img">
										<a  href="showmore?id=${info.id}" target="_blank"><img src="${info.g_main_image }" alt="图片" /></a>
									</div>
									<div class="new_commodity_name">
										<img src="../images/Dota-2.png" width="17" height="17" alt="" />
										<a href="showmore?id=${info.id}" target="_blank">${info.g_title }</a>
									</div>
									<div class="new_commodity_price">
										出售价：
										<span>${info.g_price /100}元</span>
									</div>
								</div>
							</c:forEach>
							</div>
							<div  id="more">显示更多</div>
				   </div>
				</c:if>
				<c:if test="${searchResult.status!=200 or  fn:length(searchResult.data) ==0}">
					<div class="cart">
					
					<!-- 购物车内容 -->
						<div class="catbox">
						<div class='text_s'>未搜索到想要的商品。。试试搜索其他商品吧~</div>
							<!-- 购物车内容end -->
						</div>
	
					</div>
				</c:if>
		</div>
		<div class="footer">
			<div class="footer_container">
				<p>
					<a href="index.html">首页</a><b>|</b>
					<a href="">关于我们</a><b>|</b>
					<a href="">意见反馈</a><b>|</b>
					<a href="">商务合作</a>
				</p>
			</div>
		</div>
		<div class="nav">
			<div class="shopper">
				<a href="shopping">
					<span><img src="../images/shopper.png" alt=""></span>
					<div class="shopper_gw" >购物车 </div>
				</a>
					<div class="shopper_nums"></div>
				
				<!-- <a href="" id="shopper_bb_a">
					<div class="shopper_bb" >我的背包 </div>
				</a> -->
				<div class="shopper_most">
					<img src="../images/top.png" alt="">
				</div>
			</div>
		</div>
	</div>
	</div>
	<input type="hidden" id="defaultSearch" name="defaultSearch" value="${searchResult.search}">
	<script src="../js/jquery-1.js"></script>
	<script src="../js/modernizr.js"></script>
	<script src="../js/classie.js"></script>
	<script src="../js/uiMorphingButton_fixed.js"></script>
	<script src="../js/login.js"></script>
	<script src="../js/loginregister.js"></script>
<script>
$(function(){
	/*  $(".tcdPageCode").createPage({
	        pageCount:Math.ceil(${searchResult.total/8}) ,
	        current:1,
	        backFn:function(p){
	           $.get("/solr/search",{page:p,rows:12,search:${searchResult.search}},function(){
	        	   
	           });
	        }
	    }); */
	 $(".commodity_news_bar_ul li .commodity_news_list_show").click(function () {
			$(".commodity_news_list").show();
			$(".pinglun").hide();
		});
		$(".commodity_news_bar_ul li .pinglun_show").click(function () {
			$(".pinglun").show();
			$(".commodity_news_list").hide();
		});
});

$("#more").click(function(){
	pageSearch();
	
});
var page=1;
//点击更多分页查询
function pageSearch(){
	page=page+1;
	$.get("../solr/search",{page:page,rows:12,search:$("#defaultSearch").val()},function(data){
		if(data.status==200&&data.data.length>0){
			var html='';
			for(var i=0;i<data.data.length;i++){
				
				html+='<div class="new_commodity_info"><div class="new_commodity_img">';
				html+='<a  href="showmore?id='+data.data[i].id+'" target="_blank"><img src="'+data.data[i].g_main_image+'" alt="图片" /></a></div><div class="new_commodity_name"><img src="../images/Dota-2.png" width="17" height="17" alt="" />';
				html+='<a href="showmore?id='+data.data[i].id+'" target="_blank">'+data.data[i].g_title+'</a></div><div class="new_commodity_price">出售价：';
				html+='<span>'+data.data[i].g_price/100+'元</span></div></div>';
				
			}
			$(".container .new_commodity_bg").append(html);
		}else{
			$("#more").html("<span style='color:red'>没有更多<span>");
		}
	});
}
function submitSearchForm(){
	var search=$(".search_input [name=search]").val();
	
   if(search==undefined||search==""){
	   $(".search_input [name=search]").val($("#defaultSearch").val())
	   search= $("#defaultSearch").val();
   }
   $("#defaultSearch").val($(".search_input [name=search]").val());
	$.get("../solr/search",{page:1,rows:12,search:search},function(data){
		if(data.status==200&&data.data.length>0){
			if($(".container .new_commodity").length>0){//说明之前已经搜索到了数据
				var html='';
				for(var i=0;i<data.data.length;i++){
					
					html+='<div class="new_commodity_info"><div class="new_commodity_img">';
					html+='<a  href="showmore?id='+data.data[i].id+'" target="_blank"><img src="'+data.data[i].g_main_image+'" alt="图片" /></a></div><div class="new_commodity_name"><img src="../images/Dota-2.png" width="17" height="17" alt="" />';
					html+='<a href="showmore?id='+data.data[i].id+'" target="_blank">'+data.data[i].g_title+'</a></div><div class="new_commodity_price">出售价：';
					html+='<span>'+data.data[i].g_price/100+'元</span></div></div>';
					
				}
				$(".container .new_commodity_bg").html(html);
			}else{//如果之前沒有数据
				$(".container  .cart").remove();
				var html=' <div class="new_commodity"><div class="new_commodity_bg">';
				for(var i=0;i<data.data.length;i++){
				
					html+='<div class="new_commodity_info"><div class="new_commodity_img">';
					html+='<a  href="showmore?id='+data.data[i].id+'" target="_blank"><img src="'+data.data[i].g_main_image+'" alt="图片" /></a></div><div class="new_commodity_name"><img src="../images/Dota-2.png" width="17" height="17" alt="" />';
					html+='<a href="showmore?id='+data.data[i].id+'" target="_blank">'+data.data[i].g_title+'</a></div><div class="new_commodity_price">出售价：';
					html+='<span>'+data.data[i].g_price/100+'元</span></div></div>';
				
				}
					html+='<div >更多</div></div>';
					$(".container").append(html);
					$("#more").click(function(){
						pageSearch();
						
					});
			}
		}else{
			
			if($(".container .new_commodity").length>0){//说明之前已经搜索到了数据
				$(".container  .new_commodity").remove();
				var html='<div class="cart">';
					html+='<div class="catbox">';
					html+="<div class='text_s'>未搜索到想要的商品。。试试搜索其他商品吧~</div>";
					html+='</div></div>';
					$(".container").append(html);
				}
			
		}
	});
}
</script>
</body></html>